-- set wifi AP and start wifimanager
function start_WifiManager(x)
    if x>30 then
        print('Error: start_WifiManager timeout')
        return 0
    end
    if wifi.ap.getip()==nil then
        print('wait module set wifi AP ...')
        n = x+1
        tmr.alarm(1, 3000, 0, function()
            set_ntp(n)
        end)
    else
        print('Start WifiManager ...')
        enduser_setup.manual(true)
        enduser_setup.start(
          function()
            print("Connected to wifi as:" .. wifi.sta.getip())
          end,
          function(err, str)
            print("enduser_setup: Err #" .. err .. ": " .. str)
          end
        );
    end
end
    
wifi.setmode(wifi.STATIONAP)
wifi.ap.config({ssid="NodeMcu", pwd="88888888", auth=wifi.WPA2_PSK})
print("\r\n******WiFi Manager on******")
print("AP_ssid='NodeMcu' AP_pwd='88888888'\r\n")
start_WifiManager(0)
